# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php81-pecl-imagick
_extname=imagick
pkgver=3.7.0
pkgrel=5
pkgdesc="PHP 8.1 extension provides a wrapper to the ImageMagick library - PECL"
url="https://pecl.php.net/package/imagick"
arch="all !x86" # https://gitlab.alpinelinux.org/alpine/aports/-/issues/12537
license="PHP-3.01"
depends="php81-common imagemagick"
checkdepends="ghostscript-fonts
	imagemagick-jpeg
	imagemagick-svg
	"
makedepends="php81-dev imagemagick-dev"
subpackages="$pkgname-dev"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz"
builddir="$srcdir/$_extname-$pkgver"

install_if="php-$_extname php$_phpv"

build() {
	phpize81
	./configure --prefix=/usr --with-php-config=php-config81
	make
}

check() {
	php81 -dextension=modules/$_extname.so --ri $_extname

	# see https://gitlab.alpinelinux.org/alpine/aports/-/issues/12537
	[ "$CARCH" = x86 ] && rm -f tests/166_Imagick_waveImage_basic.phpt
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test TESTS=--show-diff
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	local _confdir="$pkgdir"/etc/php81/conf.d
	mkdir -p $_confdir
	echo "extension=$_extname" > $_confdir/$_extname.ini
}

sha512sums="
c84408e4e4a0c46d979240e06d58d264c6bb21f3b95e3d434c8a21cd808f6c495fd453ef9c07b5c44dac81c6f205b6697f8ecaf1a65a86ce4e9052328a389ebe  php-pecl-imagick-3.7.0.tgz
"
